# -*- coding: utf-8 -*-            
# @Time : 2025/5/9 11:15
# @Author: ZZC
# @proj: BERT_NO1

# https://blog.csdn.net/gitblog_00592/article/details/141316093
from transformers import pipeline
from transformers import BertTokenizer, BertForSequenceClassification
# 加载 BERTweet 模型和分词器
model_name = "../bertweet-base"
tokenizer = BertTokenizer.from_pretrained(model_name)
model = BertForSequenceClassification.from_pretrained(model_name)
# 创建情感分析器
sentiment_analysis = pipeline("sentiment-analysis", model=model_name, tokenizer=tokenizer)

# 示例文本
# text = "You are a stupid pig."
# text = "I love you."
text = "Tôi rất thích sử dụng BERTweet cho việc phân tích cảm xúc trên Twitter."

# 进行情感分析
result = sentiment_analysis(text)
print(f"情感分析结果: {result}")
if __name__ == '__main__':
    pass
